Ditto provides a robust query engine that allows you to perform various filter operations to carry out traditional create
, read
, update
, and delete
(CRUD) operations.
write
command to upsert
, update
, and remove
documents from the Big Peer.
find
query within a write
command in a single operation. Instead, perform each as separate API calls. For instructions, see Performing Find and Write Operations.{app_id}
with the ID Ditto generated when you created your app in the portal.
curl
command to perform a complete upsert
operation to explicitly create or replace a document.
In this example, a friends
key contains a register
of the array
type, alongside orderCount
which functions as a counter
.
registers
and counters
, see the Platform Manual > Data Types.upsert
, use the valueTypeOverrides
payload to create or modify a mutable type, such as a register map
or a counter
, in your request. For example, instead of using the default type, you explicitly specify to create a counter
instead.
array
behaves as a register
by default. This means you do not need to explicitly specify an array
as a register
in your request.For more information, see the Platform Manual > REGISTER.update
to make changes in the Big Peer, you can include any of the following subcommands within your update
command to perform specific actions:
Subcommand | Description |
---|---|
set | Sets a specific value for a given field property. |
increment | Increments the value of a counter . |
replaceWithCounter | Replaces the current value with the counter . |
remove
command to delete documents from the Big Peer and all Small Peers connected in the mesh network.
Once deleted, Ditto indicates a document’s removal by creating a tombstone document. A tombstone contains metadata indicating that the associated data has been removed. Ditto creates a single tombstone for each document ID that matches the specified query.
To ensure that all Small Peers connected in the mesh network are aware that the document has been deleted, the tombstone, once created, triggers a change event that propagates across the mesh network as a record of its removal.
remove
operations, tombstones will be an “invisible” source of disk usage with no upper bound.For this reason, we strongly encourage the use of evict
(combined with a thoughtful subscription and soft-delete strategy) instead. Learn more about EVICT.remove
a document from the people
collection where the name
field is set to the value of John
: